package org.spring.cloud.controller;

import org.spring.cloud.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@RequestMapping("/user")
@RestController
@DefaultProperties(defaultFallback="defaultFallBack")//全局熔断提示
public class UserClientController {

	@Autowired
	private UserService userService;
	
	@RequestMapping("say")
	@HystrixCommand
	public String say(){
		 return  this.userService.say();
	}
	
	@RequestMapping("queryAll")
	@HystrixCommand
	public Object queryAll(){
		return  this.userService.queryAll();
	}
	
	@RequestMapping("getIp")
	@HystrixCommand
	public Object getIp(){
		return  this.userService.getIp();
	}
	
	public String defaultFallBack(){
		   return "sorry,对不起，请求失败";
	}
	
}
